package com.qqtech.qquan.user.controller;

import javax.annotation.Resource;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qqtech.core.frame.model.PageKit;
import com.qqtech.core.frame.model.PageOrder;
import com.qqtech.core.frame.model.Result;
import com.qqtech.core.frame.service.BaseService;
import com.qqtech.qquan.user.enums.UserHelpStatusDictEnum;
import com.qqtech.qquan.user.model.UserHelp;
import com.qqtech.qquan.user.model.UserHelpQuery;
import com.qqtech.qquan.user.model.UserHelpVo;
import com.qqtech.qquan.user.service.UserHelpService;
import com.qqtech.web.context.BaseWebController;

@Controller
@RequestMapping(value = "/user/help")
public class UserHelpController extends BaseWebController<UserHelp, UserHelpQuery> {
	@Resource
	private UserHelpService userHelpService;
    
	@Override
	protected BaseService<UserHelp> getBaseService() {
		return userHelpService;
	}
	
	/**
	 * 列表
	 * 
	 * @param userHelpQuery
	 * @return
	 */
	@RequestMapping(value = "/page")
	@ResponseBody
	public Result page(@RequestBody UserHelpQuery userHelpQuery) {
		Result result = new Result();
		userHelpQuery.setStatus(UserHelpStatusDictEnum.NORMAL.getCode());
		Pageable pageKit = new PageKit(userHelpQuery.getPage(), new PageOrder(Direction.ASC, "oidx"));
		Page<UserHelp> page = userHelpService.queryPageList(userHelpQuery, pageKit);
		result.put("page", page);
		return result;
	}
	
	@RequestMapping(value = "/detail")
	@ResponseBody
	public Result detail(@RequestBody UserHelp userHelp) {
		Result result = new Result();
		UserHelpVo detail = userHelpService.getById(userHelp.getId());
		result.put("detail", detail);
		return result;
	}
}
